<template>
  <div class="body">
    <el-menu
      :default-active="activeIndex"
      background-color="#F5F6FA"
      active-text-color="#1795FF"
      text-color="#333333 "
      class="el-menu-demo"
      mode="horizontal"
    >
      <el-menu-item @click="companylist(1)" index="1">正常</el-menu-item>
      <el-menu-item @click="companylist(2)" index="2">预警</el-menu-item>
    </el-menu>
    <el-row class="mb8">
      <el-col :span="18">
        <el-button
          type="info"
          @click="shuaxin"
          icon="el-icon-refresh-right"
        ></el-button>
      </el-col>
      <el-col :span="6" class="seach">
        <el-input
          v-model="params.keywords"
          placeholder="请输入关键字"
        ></el-input>
        <el-button
          type="primary"
          icon="el-icon-search"
          @click="shuaxin"
        ></el-button>
      </el-col>
    </el-row>
    <el-table
      ref="multipleTable"
      :data="tableData"
      tooltip-effect="dark"
      class="table"
      @selection-change="handleSelectionChange"
      height="100%"
    >
      <el-table-column align="center" type="selection" width="55">
      </el-table-column>
      <el-table-column align="center" prop="id" label="序号" width="55">
        <!-- <template slot-scope="scope">{{ scope.id }}</template> -->
      </el-table-column>
      <el-table-column
        align="center"
        prop="username"
        label="反担保人姓名"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        align="center"
        prop="mobile"
        label="反担保人手机号"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        align="center"
        prop="cardcode"
        label="反担保人身份证号"
        show-overflow-tooltip
        width="200"
      >
      </el-table-column>
      <el-table-column
        align="center"
        prop="cardback"
        label="反担保人身份证正面"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          <el-image
            :src="$baseUrl + scope.row.cardfront"
            style="height: 45px; width: 45px"
          ></el-image>
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="cardfront"
        label="反担保人身份证反面"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          <el-image
            :src="$baseUrl + scope.row.cardback"
            style="height: 45px; width: 45px"
          ></el-image>
        </template>
      </el-table-column>
      <!-- <el-table-column align="center" label="操作">
          <template slot-scope="scope">
            <el-button size="mini" @click="detailViews(scope.row)">查看详情</el-button>
          </template>
        </el-table-column> -->
    </el-table>
    <div class="block">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :page-sizes="[10, 20, 30]"
        :page-size="params.pageSize"
        :current-page.sync="params.pageNum"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import { fdbuserlist } from "@/api/guarantee";
export default {
  data() {
    return {
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      opens: false,
      params: {
        pageSize: 10,
        pageNum: 0,
        keywords: "",
        type: "1",
      },
      total: null,
      // 表单参数
      form: {
        name1: "",
        name2: "",
        name3: "",
        dept: "",
        user_id: "",
        lc_id: "",
        bm_id: "",
        bm_name: "",
        staff_id: "",
        staff_name: "",
        operation: "",
        dengji: "",
      },
      // 表单校验
      rules: {},
      options1: [], //选择部门
      options2: [], //选择职位
      btype: [],
      options3: [], //选择小组
      options4: [], //选择小组
      currentPage1: 5,
      currentPage2: 5,
      currentPage3: 5,
      currentPage4: 4,
      tableData: [],
      multipleSelection: [],
      liuch: {
        user_id: sessionStorage.getItem("id"),
        lc_name: "",
        gtype: "",
      },
      buzhl: false,
      buzhilist: [],
      activeIndex: "1",
      open6: false,
    };
  },
  created() {
    this.lists();
  },
  methods: {
    //页面
    shuaxin() {
      this.lists();
    },
    lists() {
      fdbuserlist(this.params).then((response) => {
        console.log(response);
        this.tableData = response.data.rows;
        this.total = response.data.total;
      });
    },
    companylist(num) {
      this.params.pageNum = 1;
      this.params.pageSize = 10;
      this.params.type = num;
      this.lists();
    },
    handleSelectionChange() {},
    // 分页
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.params.pageSize = val;
      this.lists();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.params.pageNum = val;
      this.lists();
    },
    // 搜索
    seach() {
      this.params.pageNum = 1;
      this.params.pageSize = 10;
      this.lists();
    },
  },
};
</script>

<style scoped lang="scss">
.body {
  height: calc(90vh - 60px);
  display: flex;
  flex-direction: column;
}

.table {
  width: 100%;
  // margin-top: 10px;
}

.block {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding-top: 0 !important;
  padding-bottom: 10px;
}

.el-select {
  width: 100% !important;
}

.el-menu--horizontal > .el-menu-item {
  height: 40px;
  line-height: 40px;
}

.el-menu.el-menu--horizontal {
  margin-bottom: 8px;
}
</style>
